
let arr: [] = [];

/**
 * 让加入其中的promise,一个接一个串行执行.
 */
export class PromiseSerialQueue {
    arr: Promise<any>[] = [];
    private _rootPromise: Promise<any> | null;
    get rootPromise(): Promise<any> {
        if (!this._rootPromise) {
            this._rootPromise = Promise.resolve("")
        }
        return this._rootPromise;
    }

    addTask(p: Promise<any>) {
        this._rootPromise = this.rootPromise.then(()=>{
            return p;
        })
    }
}
